package com.lagou.controller;

import com.alibaba.druid.stat.TableStat;
import com.lagou.domain.Dept;
import com.lagou.service.DeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/department")
public class DeptController {

    @Autowired
    private DeptService deptService;

    @RequestMapping("/findAll")
    @ResponseBody
    public List<Dept> findAll(){

        List<Dept> dept = deptService.findAll();
        return dept;
    }

    @RequestMapping("/findById")
    public String findById(Integer dept_id, Model model){

        Dept dept = deptService.findById(dept_id);
        model.addAttribute(dept);
        return "list";
    }
}
